<!--
 * @Descripttion: 
 * @Author: zhanyi
 * @Date: 2021-10-27 14:14:37
 * @FilePath: \wczd-mobile\src\pages\archives\archives.vue
-->
<template>
  <div class="safeCheck">
    <div class="globalTitle">
      <div class="top-panel-cont">
        <image class="_image_icon" @click="back" src="@/static/wczd/back.png" alt=""></image>
        <div class="title">{{form.name}}</div>
      </div>
    </div>
    <div class="globalTitle-describe">
      <p>带队领导：{{form.leader}}</p>
      <p>参与人员：{{form.member}}</p>
      <p>检查时间：{{form.inspectTime}}</p>
    </div>
    <zPaging class="_sxwh_box" :default-page-size="10" :fixed='false' :height="'100%'" ref="paging" @query="queryList" v-model="jobManagerData" :delay='200' :refresher-end-bounce-enabled="false">
      <div class="_box_item" v-for="(item,index) in jobManagerData" :key="index">
        <div class="_title" @click="_goInfo(item)">
          <div class="_left">{{item.safeCompanyName}}</div>
          <div class="_right">
            <image class="_image_icon" src="@/static/wczd/more.png" alt="">
          </div>
        </div>
      </div>
    </zPaging>
  </div>
</template>

<script>
import SearchBar from "@/components/uni-search-bar/uni-search-bar.vue";
import { safetyCheckList, safetyCheckOne, safeInspectCompanyList } from "@/api/safeCheck";
import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
import ZPagingMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin'
import customNomore from '@/pages/component/custom-nomore/custom-nomore.vue'
import moment from "moment";

export default {
  name: 'archives',
  components: { SearchBar, zPaging, customNomore },
  mixins: [ZPagingMixin],
  data () {
    return {
      searchValue: "",
      securityType: null,
      jobManagerData: [],
      form: {},
      inspectId: null
    }
  },
  onShow () {
    this.queryList(1, 10)
  },
  onLoad: function (option) {
    this.inspectId = option.id
    this.safetyCheckOne(option.id)
  },
  methods: {
    // z-paging 查询方法
    queryList (pageNo, pageSize) {
      uni.showLoading({
        title: '加载中'
      });
      safeInspectCompanyList({ inspectId: this.inspectId }, { pageNum: pageNo, pageSize: pageSize }).then(res => {
        this.$refs.paging.complete(res.rows);
        uni.hideLoading();
      })
    },
    // 重置表单
    reset () {
      this.form = {
        companyId: null,
        companyName: null,
        inspectTime: null,
        leader: null,
        member: null,
        name: null,
        safeCompany: null,
        safeCompanyParse: null,
        safeCompanyIds: null,
        safeCompanyIdsParse: null,
        status: null,
      }
    },
    // 安全检查单条
    safetyCheckOne (id) {
      this.reset()
      safetyCheckOne({ id: id }).then(response => {
        if (response.code === 200) {
          for (const d in this.form) {
            this.form[d] = response.data[d]
          }
          this.form.id = id
          this.form['safeCompanyParse'] = response.data.safeCompany?.split(',') || []
          this.form['safeCompanyIdsParse'] = response.data.safeCompanyIds?.split(',') || []
        }
      })
    },
    back () {
      uni.navigateBack({
        delta: 1
      });
    },
    _goInfo (item) {
      uni.navigateTo({
        url: `/pages/safeCheck/safeCheckDanger?resCompanyId=${item.id}&inspectId=${item.inspectId}&safeCompanyId=${item.safeCompanyId}&safeCompanyName=${item.safeCompanyName}`,
      })
    }
  },
}
</script>

<style scoped lang="scss">
.safeCheck {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.globalTitle {
  position: fixed;
  background: #fff;
  z-index: 99;
	height: 120upx;
  .addBtn {
    position: absolute;
    right: 40upx;
    top: 30upx;
    padding: 6upx 16upx;
    background-color: #ffb500;
    border-radius: 10upx;
    color: #fff;
  }
  .title {
    width: 60%;
  }
}
._sxwh_box {
  flex: 1;
  height: 0;
}
.title {
  padding-left: 0;
}
.top-panel-cont {
  display: flex;
  align-items: center;
  image {
    margin-left: 30upx;
    margin-top: 20upx;
    width: 56upx;
    height: 56upx;
  }
  div {
    font-size: 40upx;
    font-weight: bold;
  }
}
.archives {
  position: absolute;
  padding: 0 30upx 0 40upx;
  width: 100%;
  margin-top: 0;
  bottom: 0upx;
  p {
    font-size: 28upx;
  }
}
.globalTitle-describe {
  padding-top: 150upx;
  background-color: #fff;
  p {
    padding: 0 30upx 0 40upx;
    line-height: 80upx;
    font-size: 28upx;
    border-bottom: 1px rgb(236, 236, 236) solid;
  }
}
._footer {
  margin-top: 20upx;
}
._sxwh_box {
  overflow-y: scroll;
  flex: 1;
  height: 0;
}
</style>
